package ${servicePackage}.impl;

import java.util.List;
import java.util.Map;
import ${packagePath}.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ${servicePackage}.${className}Service;
import ${daoPackage}.${className}Mapper;
import ${entityPackage}.${className};
import ${voPackage}.${className}VO;



@Service("${classname}Service")
public class ${className}ServiceImpl implements ${className}Service {

	@Autowired
	private ${className}Mapper ${classname}Mapper;

	@Override
	public ${className}VO findBy${pk.attrName}(${pk.attrType} ${pk.attrname}) {
        ${className} ${classname} = ${classname}Mapper.findBy${pk.attrName}(${pk.attrname});
        return BeanUtil.copyBean(${classname}, ${className}VO.class);
	}

<#list keys as key>
    @Override
    public ${className}VO findBy${key.attrName}(${key.attrType} ${key.attrname}) {
        ${className} ${classname} = ${classname}Mapper.findBy${key.attrName}(${key.attrname});
        return BeanUtil.copyBean(${classname}, ${className}VO.class);
    }
</#list>

    @Override
    public List<${className}VO> list(Map<String, Object> params, Integer pageNum, Integer pageSize) {
        List<${className}> list = ${classname}Mapper.list(params, pageNum, pageSize);
        return BeanUtil.copyList(list, ${className}VO.class);
	}

    @Override
    public int deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}) {
        return ${classname}Mapper.deleteBy${pk.attrName}(${pk.attrname});
	}

    @Override
    public int update(${className}VO ${classname}) {
        return ${classname}Mapper.update(BeanUtil.copyBean(${classname}, ${className}.class));
	}

    @Override
    public int save(${className}VO ${classname}) {
        return ${classname}Mapper.save(BeanUtil.copyBean(${classname}, ${className}.class));
	}

}
